#pragma once
#include <osg/Matrix>
#include <osg/Vec3>
struct frame
{
	frame(osg::Vec3d _p1H, osg::Vec3d _p2HL, osg::Vec3d _p2HR, osg::Vec3d _p1W, osg::Vec3d _p2WL, osg::Vec3d _p2WR)
	{
		p1H = _p1H;
		p2HL = _p2HL;
		p2HR = _p2HR;
		p1W = _p1W;
		p2WL = _p2WL;
		p2WR = _p2WR;
	}
	frame(){}
	osg::Vec3d p1H;
	osg::Vec3d p2HL;
	osg::Vec3d p2HR;
	osg::Vec3d p1W;
	osg::Vec3d p2WL;
	osg::Vec3d p2WR;


};
struct Conversion
{
	osg::Vec2d pixel;
	osg::Vec2d eyeL;
	osg::Vec2d eyeR;
	bool useIt;
	osg::Vec2d eyeLAvg;
	osg::Vec2d eyeRAvg;
	double sttL;
	double sttR;
	Conversion* next;
	Conversion()
	{
		next = NULL;
		useIt = true;
	}
};
struct Line
{
	double m;
	double b;
};
struct Cal
{
	osg::Vec4d upLeft;
	osg::Vec4d upCenter;
	osg::Vec4d upRight;

	osg::Vec4d midleLeft;
	osg::Vec4d midleCenter;
	osg::Vec4d midleRight;

	osg::Vec4d downLeft;
	osg::Vec4d downCenter;
	osg::Vec4d downRight;
};
class Utilities
{
public:
	Utilities();
	~Utilities();
	/*************************************************************
	This function Create a Matrix that transfor from Head coordinates system to 
	World(camera) coordinates system.

	Input:
	osg::Vec3d position	:	head position
	osg::Vec3d angles	:	head orientation

	Output			:  Matrix transform
	**************************************************************/
	static osg::Matrixd headToWorld(osg::Vec3d position, osg::Vec3d angles);
	/*************************************************************
	This function Create a Matrix that transfor from World(camera) coordinates system to
	Head coordinates system.

	Input:
	osg::Vec3d position	:	head position
	osg::Vec3d angles	:	head orientation

	Output			:  Matrix transform
	**************************************************************/
	static osg::Matrixd worldToHead(osg::Vec3d position, osg::Vec3d angles);

	/*************************************************************
	This function Get Angles from Rotation Matrix
	Head coordinates system.

	Input:
	osg::Matrixd mat	: rotation Matrix

	Output			:  
	osg::Vec3		: angles (Degrees)
	**************************************************************/
	static osg::Vec3 	  MatrixGetRotation(osg::Matrixd mat);
	/*************************************************************
	This function Get Angles from Rotation Matrix
	Head coordinates system.

	Input:
	osg::Matrixd mat	: rotation Matrix

	Output			:
	double &rz		:   roll	(Degrees)
	double &rx		:	pitch	(Degrees)
	double &ry		:	heading	 (Degrees)
	return 			: void 
	**************************************************************/
	static void	MatrixGetRotation(osg::Matrixd mat, double &rz, double &rx, double &ry);
	static osg::Vec2d Utilities::DirectionToHP(osg::Vec3d direction);
	static osg::Vec2d Utilities::DirectionToHP(osg::Vec3d direction, osg::Matrixd m);

};

